package com.application.lucky.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.application.lucky.R;
import com.application.lucky.widget.TitlebarView;
import com.application.mylibrary.base.BaseActivity;
import com.application.mylibrary.utils.ToastUtils;
import com.qunar.im.ui.view.bigimageview.tool.utility.ui.ToastUtil;
import com.qunar.im.ui.view.recyclerview.BaseQuickAdapter;
import com.qunar.im.ui.view.recyclerview.BaseViewHolder;

import java.util.ArrayList;
import java.util.List;

public class KeFuActivity extends BaseActivity {

    private TitlebarView mTitleBar;
    private RecyclerView mRclView;
    private MyAdapter myAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        initView();
        initListener();
    }

    private void initListener() {
        mTitleBar.setOnViewClick(new TitlebarView.onViewClick() {
            @Override
            public void leftClick() {
                finishAnim();
            }

            @Override
            public void rightClick() {

            }
        });
    }

    @Override
    public void beforeInit() {

    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_ke_fu;
    }

    private void initView() {
        mTitleBar = (TitlebarView) findViewById(R.id.title_bar);
        mRclView = (RecyclerView) findViewById(R.id.rcl_view);
        mRclView.setLayoutManager(new LinearLayoutManager(this));
        List<String> datas = new ArrayList<>();
        datas.add("存取款问题咨询");
        datas.add("游戏问题咨询");
        datas.add("优惠活动咨询");
        datas.add("申请代理咨询");
        datas.add("其他问题咨询");
        myAdapter = new MyAdapter(R.layout.item_kefu_layout, datas);
        myAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                ToastUtils.show("点击了"+myAdapter.getItem(position)+"功能还没有实现");
            }
        });
        mRclView.setAdapter(myAdapter);
    }

    static class MyAdapter extends BaseQuickAdapter<String, BaseViewHolder> {

        public MyAdapter(int layoutResId, @Nullable List<String> data) {
            super(layoutResId, data);
        }

        @Override
        protected void convert(BaseViewHolder helper, String item) {
            helper.setText(R.id.tv_item_kefu, item);
        }
    }
}
